
#ifndef ORIGIN_H
#define ORIGIN_H

#include <stdio.h>
#include <GL/glut.h>
#include<GL/glui.h>
#include"launchSite.h"
#include "vector3f.h"


#include "glm.h"


#define rootdir "./"

//these 2 template are used for barycentric cooridates computing
template<typename T>
T min3(T* t, int len = 3) {
	int c = 0;
	for (int i = 0; i < len; i++)
		if (t[i] < t[c])
			c = i;
	return t[c];
}

template<typename T>
T max3(T* t, int len = 3) {
	int c = 0;
	for (int i = 0; i < len; i++)
		if (t[c] < t[i])
			c = i;
	return t[c];
}

class Origin {

private:

	int
	w_width, w_height;

	vector3f
	spin, lastspin, anchor;
	GLMmodel *pmodel;
	floatbuffer zbuf;

public:
	Origin(int width, int height);
	virtual ~Origin();
	void drawmodel(void);

	void loadmodel(char* name);
	bool baryCoord(float m, float n, float* x, float* v, float* b);
	floatbuffer* getdepthbuffer();


	//glut call backs!
	void display();
	void reshape(int width, int height);
	void menu(int value);
	void keyboard(unsigned char key, int x, int y);
	void motion(int x, int y);
	void mouse(int button, int state, int x, int y);

};

#endif
